﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;

namespace MicroLink.StsDev2008AddIn.CommandHandlers
{
    [CommandID(GuidList.guidStsDev2008AddInCmdSetString, PkgCmdIDList.cmdidDeployedSolutions)]
    internal sealed class DisplayDeployedSolutionsHandler : MenuCommandHandler
    {
        public DisplayDeployedSolutionsHandler(Package package)
            : base(package)
        {
        }

        protected override void OnExecute(Microsoft.VisualStudio.Shell.OleMenuCommand command)
        {
            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            ToolWindowPane window = Package.FindToolWindow(typeof(MyToolWindow), 0, true);
            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException(Resources.CanNotCreateWindow);
            }
            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

            base.OnExecute(command);
        }
    }
}
